/* eslint-disable */
import { MENU_CODES, METHOD_TYPE, MODULES } from '@/options';
import useBaseRequest from '@/hooks/useBaseRequest';
import { request } from '@umijs/max';
import { Result } from '@/types/common/request';

type DataType = ROLE_TYPE.Info;
type Params = ROLE_TYPE.Params;
const ApiUrl = `/${MODULES.SYSTEM}/${MENU_CODES.ROLE}`;

export const { getList, addItem, updateItem, delItem, detailItem } = useBaseRequest<
  DataType,
  Params
>(ApiUrl);

export const getRoleMenuList = (
  roleId: ROLE_TYPE.RoleMenuList['roleId'],
  options?: { [key: string]: any },
) => {
  return request<Result<ROLE_TYPE.MenuList>>(ApiUrl + '/menuList', {
    method: METHOD_TYPE.GET,
    params: {
      roleId,
    },
    ...(options || {}),
  });
};

export const setRoleMenuList = (data: ROLE_TYPE.RoleMenuList, options?: { [key: string]: any }) => {
  return request<Result<string>>(ApiUrl + '/menuInsert', {
    method: METHOD_TYPE.POST,
    data,
    ...(options || {}),
  });
};
